<template>
  <div>
    <div class="btn">
      <el-button type="primary" @click="add">添加</el-button>
    </div>
    <v-table :arr="arr" :info="info" @init="init" @update="update"></v-table>
    <v-window :info="info" @init="init" ref="addInfo"></v-window>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
import { rolelist } from "../../http/api";
import vTable from "./component/table.vue";
import vWindow from "./component/window.vue";
export default {
  components: {
    vTable,
    vWindow,
  },
  data() {
    return {
      arr: [],
      info: {
        isshow: false,
        isAdd: true,
      },
    };
  },
  computed: {
    ...mapGetters({}),
  },
  methods: {
    ...mapActions({}),
    add() {
      this.info.isshow = true;
      this.info.isAdd = true;
    },
    init() {
      rolelist().then((res) => {
        if (res.data.code == 200) {
          this.arr = res.data.list;
        }
      });
    },
    update(id){
      this.$refs.addInfo.getOne(id);
    }
  },
  mounted() {
    this.init();
  },
};
</script>

<style lang="less" scoped>
@import "../../less/index.less";
.btn {
  margin-bottom: @margin;
}
</style>